package config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;

@EnableWebFlux
@Configuration
@ComponentScan({"controller", "filter", "handler", "service", "config.security"})
public class MvcConfig implements WebFluxConfigurer {
//    @Bean
//    public JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter() {
//        return new JwtAuthenticationTokenFilter();
//    }
    @Override
    public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
//        List<HttpMessageWriter<?>> writers = configurer.getWriters();
//        writers = null;
//        System.out.println();
//        List<HttpMessageReader<?>> readers = configurer.getReaders();
//        configurer.getWriters().add()
//        System.out.println();
        ServerCodecConfigurer.ServerDefaultCodecs serverDefaultCodecs = configurer.defaultCodecs();
//        serverDefaultCodecs.
    }

    @Override
    public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {

//        configurer.addCustomResolver(new FormDataRe());

    }

    /**
     * cros跨域
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedHeaders("*")
                .allowCredentials(true).maxAge(3600);
    }
}
